﻿using Deployment.Data.Environment.Connection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Deployment.Data.UI.Controls.Connection
{
    /// <summary>
    /// Interaction logic for ConnectionEditorControl.xaml
    /// </summary>
    public partial class ConnectionEditorControl : UserControl
    {
        private bool _EditMode = false;

        public ConnectionEditorControl()
        {
            InitializeComponent();
        }

        internal bool IsEditMode
        {
            get { return _EditMode; }
            set
            {
                _EditMode = value;
            }
        }

        private class StringComparer : IEqualityComparer<string>
        {

            public bool Equals(string x, string y)
            {
                return string.Equals(x, y, StringComparison.CurrentCultureIgnoreCase);
            }

            public int GetHashCode(string obj)
            {
                return obj.GetHashCode();
            }
        }

        
        private void EditorControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (_EditMode)
            {
                if (EditorControl.DataContext != null)
                {
                    AbstractConnection con = EditorControl.DataContext as AbstractConnection;
                    if (con != null)
                    {
                        cbo_ConnectionType.ItemsSource = new List<AbstractConnection>(new AbstractConnection[] { con });
                        cbo_ConnectionType.SelectedItem = con;
                        cbo_ConnectionType.IsEnabled = false;
                    }
                }
            }
        }

        private void cbo_ConnectionType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }


    }
}
